<?php
include ("clientinfo.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>商品销售出库</title>
    <script type="text/javascript" src="js/time.js"></script>
    <script src="jquery.js" ></script>
    <script >
        function test() {
            document.addclient.submit();
        }
        //添加触发自动计算sum的功能
        window.onload = function(){
            var num = document.getElementById('num');
            var price = document.getElementById('price');
            var sum = document.getElementById('sum');
            num.onkeyup = price.onkeyup = function(){
                if(isNaN(price.value) || isNaN(num.value) || !price.value || !num.value){
                    sum.value = '0';
                    return;
                }
                sum.value = parseFloat(price.value) * parseFloat(num.value);
            }
        }
        //修改触发自动计算sum的功能
        function sumUpdate(id){
            var numId="num"+id;//先声明变量
            var priceId="price"+id;
            var sumId="sum"+id;
            var num=document.getElementById(numId);//调用变量的值
            var price=document.getElementById(priceId);
            var sum=document.getElementById(sumId);
            if(isNaN(price.value) || isNaN(num.value) || !price.value || !num.value){
                sum.value = '0';
                return;
            }
            sum.value = parseFloat(price.value) * parseFloat(num.value);
        }
    </script>
</head>
<body background="../../money/pic/topbg.jpg">
    <table width="98%" height=""  border="0" cellpadding="0" cellspacing="0" >
        <tr>
            <td height="22" valign="top" class="word_orange">当前位置：导航栏&gt;  商品销售出库 &gt; &gt; </td>
        </tr>
     </table>
    <br>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
            <table width="95%"  border="1" cellpadding="0" align="center" cellspacing="0" bordercolor="#FFFFFF" bordercolordark="#D2E3E6" bordercolorlight="#FFFFFF">
                <tr align="center" bgcolor="#e3F4F7">
                    <th>客户名称</th>
                    <th>商品名称</th>
                    <th>购买数量</th>
                    <th>商品单价</th>
                    <th>总金额</th>
                    <th>购买时间</th>
                    <th>客户电话</th>
                    <th>客户地址</th>
                    <th>客户开户银行</th>
                    <th>客户银行账号</th>
                    <th>操作</th>
                 </tr>
            <?php foreach($clientl as $value){ ?>
                <tr>
                    <form action="client.php" method="post" name="updateclient" >
                        <td><input type="text" name="name" value="<?php echo $value[0] ?>" size="10"/></td>
                        <td><input  disabled="disabled" type="text" id="producenamel" size="10"
                                    value=" <?php echo $value[1] ?>" />
                        </td>
                        <td><input type="text" id="<?php echo "num".$value[9]?>" name="num" value="<?php echo $value[2] ?>" size="7" onchange="sumUpdate(<?php echo $value[9]?>)"/></td>
                        <td>
                            <input disabled="disabled" type="text" size="10" id="<?php echo "price".$value[9]?>" name="price" size="10" value="<?php echo $value[10] ?>"  />
                        </td>
                        <td><input type="text" name="sum" id="<?php echo "sum".$value[9]?>" value="<?php echo $value[2]*$value[10]?>" size="10"/></td>
                        <td><input type="text" name="buytime" value="<?php echo $value[4] ?>" size="10" style="border:1px solid #999;" onclick="fPopCalendar(event,this,this)" onfocus="this.select()" readonly="readonly" /></td>
                        <td><input type="text" name="phone" value="<?php echo $value[5] ?>" size="10"/></td>
                        <td><input type="text" name="adress" value="<?php echo $value[6] ?>"/></td>
                        <td>
                            <input type="text" name="bankname" value="<?php echo $value[7] ?>" size="15"/>
                        </td>
                        <td><input type="text" name="bankid" value="<?php echo $value[8] ?>" size="15"/></td>
                        <td>
                            <input type="hidden" name="id" value="<?php echo $value[9] ?>"/>
                            <input type="submit" name="updateclient" value="修改" />
                        </td>
                    </form>

                    <form action="client.php" method="post" name="delclient" >
                        <td>
                            <input type="hidden" name="id" value="<?php echo $value[9] ?>"/>
                            <input type="submit" name="delclient" value="删除" />
                        </td>
                    </form>
                </tr>
            <?php }?>
                <tr>
                    <form action="client.php" method="post" name="addclient" >
                        <td><input type="text" name="name" value="<?php echo @$addClients['name']  ?>" size="10"/></td>
                        <td><select name="producename" id="select" onchange="test()" >
                                <option>--请选择--</option>
                                <?php foreach($cproduce1 as $value1) { ?>
                                    <option value="<?php echo $value1[1] ?>" <?php if(@$_POST['producename']==$value1[1])  echo  "selected" ?>>
                                        <?php echo $value1[1] ?>
                                    </option>
                                <?php } ?>
                            </select>
                        </td>
                        <td><input type="text" id="num" name="num" value="<?php echo @$addClients['num']  ?>" size="7"/></td>
                        <td><input  type="text" id="price" name="price" size="10"
                            <?php foreach ( $cproduce1 as $value2) { ?>
                             <?php if(@$addClients['producename']==$value2[1]){ ?>
                                value=" <?php echo $value2[2] ?>" />
                            <?php }} ?>
                        </td>
                        <td><input type="text" name="sum" id="sum" value="<?php echo @$addClients['sum']  ?>" size="10"/></td>
                        <td><input type="text" name="buytime" value="<?php echo @$addClients['buytime']  ?>" size="10" style="border:1px solid #999;" onclick="fPopCalendar(event,this,this)" onfocus="this.select()" readonly="readonly" /></td>
                        <td><input type="text" name="phone" value="<?php echo @$addClients['phone']  ?>" size="10"/></td>
                        <td><input type="text" name="adress" value="<?php echo @$addClients['adress']  ?>"/></td>
                        <td><select name="bankname" value="<?php echo @$addClients['bankname']  ?>" <?php echo  "selected" ?>>
                                <option>--请选择--</option>
                                <option value="中国建设银行" >中国建设银行</option>
                                <option value="中国农业银行 " >中国农业银行</option>
                                <option value="中国工商银行" >中国工商银行</option>
                                <option value="中国招商银行" >中国招商银行</option>
                                <option value="中国农村信用社" >中国农村信用社</option>
                                <option value="中国华夏银行" >中国华夏银行</option>
                            </select>
                        </td>
                        <td><input type="text" name="bankid" value="<?php echo @$addClients['bankid']  ?>" size="15"/></td>
                        <td>
                            <input type="hidden" name="id" value="<?php echo @$addClients['id']  ?>"/>
                            <input type="submit" name="addclient" value="添加" />
                        </td>
                    </form>
                 </tr>

        </table>
    </table>
    </body>
</html>